<template>
  <view class="container">

    <view class="avatar">
      <!-- 上传组件 -->
      <u-upload
        name="product_img"
        :maxCount="1"
        :fileList="filelist"
        width="100"
        height="100"
      
      />
    </view>
    <view class="content">
      <u-form
        labelPosition="left"
        labelWidth="60"
        :model="buslevel"
        :rules="rules"
        ref="product"
      >
        <!-- 名称 -->
        <u-form-item label="会员昵称" prop="name">
          <u-input v-model="buslevel.nickname" disabled />
        </u-form-item>

        <!-- 商品描述 -->
        <u-form-item label="等级" prop="levelname_text" borderBottom>
          <u-input
          disabled
            v-model="buslevel.levelname_text"
            placeholder="会员等级未知"

          />
        </u-form-item>
        <u-form-item label="有效期" prop="expdate_text">
          <u-input
          disabled
            v-model="buslevel.expdate_text"
            placeholder="会员有效期未知"
          />
        </u-form-item>

        <!-- 参数3 -->
        <u-form-item label="创建时间" prop="createtime_text">
          <u-input v-model="buslevel.createtime_text" disabled />
        </u-form-item>

     
        <!-- 提交按钮 -->
        <u-button
          text="修改会员"
          icon="pushpin"
          size="small"
          type="success"
          :customStyle="btnStyle"
          @click="product"
        />
      </u-form>
    </view>
    <!-- 消息提醒 -->
    <u-toast ref="notice"></u-toast>
  </view>
</template>
  
<script>
export default {
  onLoad(options) {
    this.auth = this.$u.auth.check();

    console.log(options)

    this.leveid = options.leveid ? options.leveid : 0
    this.busid = options.busid ? options.busid : 0

    this.list();
  },

  onReady() {
    this.$refs.product.setRules(this.rules);
  },
  created() {
    setInterval(() => {
       this.$u.count.check();
    }, 15000);
  },
  data() {
    return {
      filelist: [],
      auth: {},
      leveid: 0,
      busid:0,
      thumbs_text: "",
      buslevel: {
       
      },
      piclist: [],

      rules: {
        zhekou: {
          required: true,
          message: "折扣不能为空",
          trigger: ["change"],
        },
        detaile: {
          required: true,
          message: "不低于3个字",
          trigger: ["change"],
        },
        name: {
          required: true,
          message: "请填写套餐标题",
          trigger: ["blur", "change"],
        },
        createtime_text: {
          required: true,
          message: "创建时间不能为空",
          trigger: ["blur", "change"],
        },
      },
    }
  },
  methods: {
    
    product() {
      this.$refs.product
        .validate()
        .then(async () => {
          var data = {
            id: this.leveid,
            name: this.buslevel.name,
            free: this.buslevel.free,
            adminid: this.auth.id,
            imagelist: this.buslevel.imagelist_text,
            detaile: this.buslevel.detaile,
            zhekou:this.buslevel.zhekou,
            thumb: this.buslevel.thumb_text,
            activityDuration:this.buslevel.actdate_text,

            carwash: this.buslevel.carwash,
          };

          let result = await this.$u.api.business.leveledit(data);

          if (result.code) {
            this.$refs.notice.show({
              type: "success",
              message: result.msg,
              duration: 1000,
              complete: () => {
                //返回上一个界面
                uni.$u.route({
                  type: "reLaunch",
                  url: "/pagesD/level/edit",
                  params: {
                    leveid: this.leveid,
                  },
                });
              },
            });
          } else {
            this.$refs.notice.show({
              type: "danger",
              message: result.msg,
              duration: 2000,
            });
          }
        })
        .catch(() => {
          uni.$u.toast("效验失败");
        });
    },
   
  }
}
</script>
  
<style >
.content {
  padding: 20px;
}

.container {
  height: 100%;
  margin: 0 50rpx;
  box-sizing: border-box;
}

.avatar {
  text-align: center;
  /* display: flex; */
  /* align-items: center; */
}

.u-avatar {
  margin: 80rpx auto 40rpx;
}

.xcx {
  width: 200rpx;
  height: 200rpx;
  margin: 80rpx auto 40rpx;
  border-radius: 100%;
  overflow: hidden;
}

.nickname {
  font-size: 14px;
  text-align: center;
}

.name {
  text-align: center;
  margin: 40rpx 0;
  font-size: 14rpx;
}

.avatar .u-upload {
  justify-content: center;
  align-items: center;
  margin: 3em auto;
}

.vedio .u-upload {
  justify-content: center;
  align-items: center;
  margin: 0.3em auto;
}

.vedio {
  text-align: center;
}

.u-vedio {
  margin: 80rpx auto 40rpx;
}
</style>
  